#include "qprojectpropertyview.h"


#include "../../libs/corelib/qpropertylistview.h"
#include "../../libs/sharedlib/qprojectcore.h"
#include "../../libs/sharedlib/qprojecthost.h"
#include "../../libs/corelib/styledbar.h"


#include <QVBoxLayout>
#include <QLabel>

QProjectPropertyView::QProjectPropertyView(QWidget *parent) :
    QWidget(parent),
    m_propertyView(new CORELIB::QPropertyListView(this)),
    m_styledBar(new CORELIB::StyledBar(this))
{

    QVBoxLayout *l=new QVBoxLayout();
    l->setMargin(0);
    l->setSpacing(0);

    l->addWidget(m_styledBar);
    l->addWidget(m_propertyView);

    this->setLayout(l);
    this->resize(200,200);

    QLabel *label=new QLabel("Project Property");
    label->setStyleSheet("color:rgb(255,255,255);");
    l=new QVBoxLayout();
    l->setMargin(5);
    l->setSpacing(0);
    l->addWidget(label);
    m_styledBar->setLayout(l);

    SHAREDLIB::QProjectCore *core=SHAREDLIB::QProjectCore::getCore();
    connect(core,SIGNAL(projectOpen()),this,SLOT(projectOpen()));
    connect(core,SIGNAL(projectClosed()),this,SLOT(projectClosed()));

    connect(m_propertyView,SIGNAL(need_make_page_position()),this,SIGNAL(need_make_page_position()));
}

void QProjectPropertyView::projectOpen()
{
    SHAREDLIB::QProjectCore *core=SHAREDLIB::QProjectCore::getCore();

    SHAREDLIB::QProjectHost* host=(SHAREDLIB::QProjectHost*)core->property("host").toInt();
    if(host!=NULL)
    {
        m_propertyView->setPropertys(host->propertys());
    }
}

void QProjectPropertyView::projectClosed()
{
    m_propertyView->clearAll();
}

bool QProjectPropertyView::pagePosition(const QVariant &param)
{
    return m_propertyView->pagePosition(param);
}

void QProjectPropertyView::make_page_position(QVariant &info)
{
    m_propertyView->page_position(info);
}

void QProjectPropertyView::set_page_position(const QVariant &info)
{
    m_propertyView->set_page_position(info);
}
